/* ========================================================================= */
/* ------------------------------------------------------------------------- */
/*!
  \file			plgmdl.h
  \date			July 2011
  \author		TNick

  \brief		Contains the definition for PlgMdl class


 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @n
 Please read ReadMe.txt and Licence.txt in root folder @n
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @n

*/
/* ------------------------------------------------------------------------- */
/* ========================================================================= */
#ifndef __PLGMDL_INC__
#define __PLGMDL_INC__
//
//
//
//
/*  INCLUDES    ------------------------------------------------------------ */

class		PlgEnvel;

#include	<QAbstractItemModel>

#include	<generic/virtype.h>
#include	<gui/plgins/plgman.h>

/*  INCLUDES    ============================================================ */
//
//
//
//
/*  CLASS    --------------------------------------------------------------- */

/// the model that may be used to display plug-ins for an application
/**
*	This model shows the plug-ins at top level and commands that
*	they contain as kids. If other standard elements will be added,
*	the model may need to be changed.
*/
class PlgMdl : public QAbstractItemModel
{
	Q_OBJECT

	//
	//
	//
	//
	/*  DEFINITIONS    ----------------------------------------------------- */

	/*  DEFINITIONS    ===================================================== */
	//
	//
	//
	//
	/*  DATA    ------------------------------------------------------------ */

private:

	/// we keep an array of envelope structures here
	PlgEnvel *			p_env;

	/*  DATA    ============================================================ */
	//
	//
	//
	//
	/*  FUNCTIONS    ------------------------------------------------------- */

public:

	/// constructor
	explicit			PlgMdl				(
		QObject		*parent = 0		/**< optional parent object*/
		);

	/// destructor;
	virtual				~PlgMdl		(void);


	/* alow fellows to trigger change signal */
	inline void			dataHasChanged(QModelIndex the_idx)
	{ emit dataChanged(the_idx, the_idx); }
	inline void			dataHasChanged(QModelIndex the_idx1, QModelIndex the_idx2)
	{ emit dataChanged(the_idx1, the_idx2); }


	inline QModelIndex	createIndex(int row, int col, void* p) const
	{ return QAbstractItemModel::createIndex(row, col, p); }


	/// number of plug-ins
	int					plgInCount(void) const;





	/// Returns the index of the item in the model specified by the given row, column and parent index.
	/**
 *	QAbstractItemModel implementation. @n
 *	When reimplementing this function in a subclass,
 *	call createIndex() to generate model indexes that
 *	other components can use to refer to items in your model.
 */
	QModelIndex			index				(
		int						row,
		int						column,
		const					QModelIndex & parent = QModelIndex()
		) const;
	/// Returns the parent of the model item with the given index, or QModelIndex() if it has no parent.
	/**
 *	QAbstractItemModel implementation. @n
 *	A common convention used in models that expose tree data
 *	structures is that only items in the first column have
 *	children. For that case, when reimplementing this function
 *	in a subclass the column of the returned QModelIndex would be 0.
 */
	QModelIndex		parent (
		const QModelIndex &		index
		) const;


	/// Returns the number of rows under the given parent.
	/**
 *	QAbstractItemModel implementation. @n
 *	When the parent is valid it means that rowCount is
 *	returning the number of children of parent.
 */
	int				rowCount				(
		const QModelIndex &		parent = QModelIndex()
		) const;

	/// Returns number of columns for this item
	/**
 *	QAbstractItemModel implementation. @n
 */
	virtual int		columnCount				(
		const QModelIndex &		parent = QModelIndex()
		) const
	{ Q_UNUSED(parent); return 1; }


	/// Returns the data stored under the given role for the item referred to by the index.
	/**
 *	QAbstractItemModel implementation
 */
	QVariant		data					(
		const QModelIndex & index,
		int						role = Qt::DisplayRole
		) const;

	/// Returns the item flags for the given index.
	/**
 *	QAbstractItemModel implementation. @n
 *	The base class implementation returns a combination of flags that
 *	enables the item (ItemIsEnabled) and allows it
 *	to be selected (ItemIsSelectable).
 */
	Qt::ItemFlags	flags					(
		const QModelIndex &		index
		) const
	{ Q_UNUSED(index); return Qt::ItemIsEnabled | Qt::ItemIsSelectable; }


	/// Returns the data for the given role and section in the header with the specified orientation.
	/**
 *	QAbstractItemModel implementation
 */
	QVariant		headerData				(
		int						section,
		Qt::Orientation			orientation,
		int						role = Qt::DisplayRole
		) const;



	/*  FUNCTIONS    ======================================================= */
	//
	//
	//
	//

};	/*	class PlgMdl	*/

/*  CLASS    =============================================================== */
//
//
//
//
#endif // __PLGMDL_INC__
/* ------------------------------------------------------------------------- */
/* ========================================================================= */

